#pragma once
#include <iostream>
#include <fstream>
#include <map>

namespace MyDitc
{
enum
{
    is_open_err = 1
};
static const std::string ditcfile  = "./ditc.txt";
static const char slicsymbol = ':';
    class Ditc
    {
        void slicing(std::string& line,std::string& str1,std::string& str2)
        {
            int pos = line.find(slicsymbol);
            str1 += line.substr(0,pos);
            str2 += line.substr(pos + 1);
        }
    public:
        Ditc()
        {
            std::ifstream in(ditcfile);
            if(!in.is_open())
            {
                exit(is_open_err);
            }
            std::string line,str1,str2;
            while(getline(in,line))
            {
                slicing(line,str1,str2);
                _ditc.insert({str1,str2});
                str1.clear();
                str2.clear();

            }
            in.close();
        }

        std::string inquiryditc(const std::string& str)
        {
            auto it = _ditc.find(str);
            if(it == _ditc.end())
                return "unknow";
            else
                return it->second;
        }
    private:
        std::map<std::string,std::string> _ditc;
    };
}